﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Coding4FunCamera
{
    public class CameraFileUtilities
    {
        public static string incrementFileNameNumber(string file)
        {
            string newFileName;
            int fileVersionNumber = 0;

            FileInfo fileInfo = new FileInfo(file);
            newFileName = fileInfo.FullName;
            if (File.Exists(newFileName))
            {
                do
                {
                    newFileName = fileInfo.DirectoryName + "\\" + fileInfo.Name.Replace(fileInfo.Extension, "") + (++fileVersionNumber) + fileInfo.Extension;
                }
                while (File.Exists(newFileName));
            }

            return newFileName;
        }
    }
}
